let context

const BROWSER = {
  versions: (function () {
    let u = navigator.userAgent
    // let app = navigator.appVersion
    return { // 移动终端浏览器版本信息
      trident: u.indexOf('Trident') > -1, // IE内核
      webKit: u.indexOf('AppleWebKit') > -1, // 苹果、谷歌内核
    }
  }()),
  language: (navigator.browserLanguage || navigator.language).toLowerCase()
}

export default {
  close() {
    if (BROWSER.versions.trident) {
      window.external.JSCallMFCFunctionClose()
    } else if (BROWSER.versions.webKit) {
      context.useFunction_Close(false)
    }
  },
  show() {
    let that = this
    if (BROWSER.versions.webKit) {
      context.SigSendMessageToJS.connect(function (message) {
        that.myData = JSON.parse(message)
      })
    }
  }
}
